import {
    request
} from '../utils/request';
//获取首页轮播图
export const reqBanner = () => request({
    url: '/mall-api/index/findBanner'
});
//获取首页导航列表的数据
export const reqNavList = () => request({
    url: `/mall-api/index/findCategory1`
});
//猜你喜欢
export const reqLike = () => request({
    url: `/mall-api/index/findListGoods`
});
//人气推荐
export const reqRecommend = () => request({
    url: `/mall-api/index/findRecommendGoods`
});
//获取分类的数据
export const reqCategory = () => request({
    url: `/mall-api/index/findCategoryTree`
});
//获取商品分页列表
export const reqGoodList = (params) => request({
    url: `/mall-api/goods/list/${params.page}/${params.limit}`,
    data: params
});
//获取token
export const reqToken = (code) => request({
    url: `/mall-api/weixin/wxLogin/${code}`
});

//获取用户信息
export const reqUserInfo = () => request({
    url: `/mall-api/weixin/getuserInfo`
});

//更新用户信息
export const reqUpdateUser = (data) => request({
    url: `/mall-api/weixin/updateUser`,
    data,
    method: 'POST'
});
//获取购物车
export const reqCart = () => request({
    url: `/mall-api/cart/getCartList`
});

//更新商品勾选状态
export const reqUpdateCart = ({
    goodsId,
    isChecked
}) => request({
    url: `/mall-api/cart/checkCart/${goodsId}/${isChecked}`
});
//全选的回调
export const reqUpdateAll = (isChecked) => request({
    url: `/mall-api/cart/checkAllCart/${isChecked}`
});

//修改数量
export const reqAddOrUpdateCount = (params) => request({
    url: `/mall-api/cart/addToCart/${params.goodsId}/${params.count}`,
    data: {
        blessing: params.blessing
    }
});
//删除某一个商品
export const reqDeleteGoods = (goodsId) => request({
    url: `/mall-api/cart/delete/${goodsId}`
});

//获取商品详情
export const reqGoodsInfo = (goodsId) => request({
    url: `/mall-api/goods/${goodsId}`
});

//获取立即购买的订单详情
export const reqFindOrder = (params) => request({
    url: `/mall-api/order/buy/${params.goodsId}?blessing=${params.blessing}`
})



//获取收件人地址
export const reqUserAddRess = () => request({
    url: '/mall-api/userAddress/getOrderAddress'
})

//提交订单
export const reqSubmitOrder = (data) => request({
    url: `/mall-api/order/submitOrder`,
    data,
    method: 'POST'
});


//获取支付信息
export const reqPayInfo = (orderId) => request({
    url: `/mall-api/webChat/createJsapi/${orderId}`
});


//查询订单状态
export const reqPayResut = (orderNo) => request({
    url: `/mall-api/webChat/queryPayStatus/${orderNo}`
});

//用户全部地址
export const reqAllAddress = () => request({
    url: `/mall-api/userAddress/findUserAddress`
})

export const reqAddAddress = (params) => {
    return request({
        url: `/mall-api/userAddress/save`,
        data: params,
        method: 'POST'
    })
}